turn from: http://blog.csdn.net/liuning800203/article/details/6455226
Releasing resources with destructors
Destructors are used to deconstruct instances of classes.
1 The destructor cannot be defined in the structure. Destructors can only be used
C + + destructor
When an object is created, the system automatically calls the constructor to initialize the work, as well as the system automatically calls a function to clean up when the object is destroyed (for example, the various resources
C + + destructor
The inherited development environment that I use: Visual Studio
How to write a destructor when designing a class.Destructors if we do not write,C + + will help us to automatically synthesize one, that is to say:C + + will
Constructor:
C ++ provides constructor to process object initialization. It is automatically executed when an object is created. The name of the constructor must be the same as the class name. It does not have any type or return any value. The
I have been talking about it for a long time. msdn also has a very detailed description, but it does not seem very systematic. I have also done some analysis, but I did not forget to summarize it. This time, I will sort out some information
Li Jianzhong (Nanjing University of Posts and Telecommunications (Cornyfield@263.net)
Constructor
The constructor initializes the member variables (fields) in the class. The C # class has two constructor types: instance constructor and static
See the following code:
Class {Public:A () {pvalue = new int [100]; printf ("constructor of A/N ");}~ A () {Delete [] pvalue; printf ("deconstructor of A/N ");}PRIVATE:Int * pvalue;};Class B {Public:~ B () {printf ("deconstructor of B/N ");}};
Class
Http://www.cnblogs.com/Hacker/archive/2010/06/02/1750383.html
With this function, you can execute the operations you want before the main function is executed and after exiting the main function. The specific principle is that there are a lot of web
The destructor of the destructor function.In C + +, ' ~ ' is a bitwise inverse operator, and you can think of a destructor as a function contrary to a constructor function. Destructors have no return value, no function type, no parameters. Because
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.